﻿using System;
using System.Windows.Forms;

namespace BugReporter
{
    public partial class BugReporterForm : Form
    {
        string m_lang;

        public BugReporterForm() {
            InitializeComponent();
        }

        public BugReporterForm( String project, String version, String exception, String exceptionMsg ) {
            InitializeComponent();

            NameLBL.Text = project;
            VersionLBL.Text = version;
            m_lang = "C#";
            ExcpRTB.Text = exception;
            ExcpMsgRTB.Text = exceptionMsg;
        }

        public BugReporterForm(String project, String lang, String version, String exception, String exceptionMsg) {
            InitializeComponent();

            NameLBL.Text = project;
            VersionLBL.Text = version;
            m_lang = lang;
            ExcpRTB.Text = exception;
            ExcpMsgRTB.Text = exceptionMsg;
        }

        private void cancelButton_Click(object sender, EventArgs e) {
            this.Hide();
        }

        private void sendButton_Click(object sender, EventArgs e) {

            HM_DA.BugReport report = new HM_DA.BugReport();
            report.Project = NameLBL.Text.Trim();
            report.Lang = m_lang;
            report.PostedDate = DateTime.Now;
            report.Version = VersionLBL.Text.Trim();
            report.Description = descriptionTB.Text.Trim();
            report.Exception = ExcpRTB.Text.Trim();
            report.ExceptionMessage = ExcpMsgRTB.Text.Trim();

            HM_DA.HangmanDefinitionWSSoapClient client = new HM_DA.HangmanDefinitionWSSoapClient("HangmanDefinitionWSSoap");
            client.Open();
            client.postBugReport( report );
            client.Close();

            this.Hide();

        }
    }
}
